package com.cat.dynamicPlanning02;

import java.util.HashSet;
import java.util.List;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/vowels-of-all-substrings/?envType=problem-list-v2&envId=dynamic-programming
 * @create 2025/11/4 18:58
 * @since JDK17
 */

public class Solution34 {
    public long countVowels(String word) {
        int n = word.length();
        long ans = 0;
        HashSet<Character> set = new HashSet<>();
        set.addAll(List.of('a', 'e', 'i', 'o', 'u'));
        for (int i = 0; i < word.length(); i++) {
            if (set.contains(word.charAt(i))) {
                ans += (long) (i + 1) * (n - i);
            }
        }

        return ans;
    }
}
